<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	StringBuffer strURL = request.getRequestURL();
	String URL = strURL.toString();
	String contPath = request.getContextPath();
	int nIndex = URL.indexOf(contPath);
	URL = "http://tugo.cn/weixin_aef/";
	%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- 移动端必须的设置 -->
<link rel="stylesheet" href="<%=URL%>newedition/css/aui.css" />
<link rel="stylesheet" href="<%=URL%>newedition/css/oiler_infoNotes.css" />
<link rel="stylesheet" href="<%=URL%>newedition/css/aui-pull-refresh.css" />
<script type="text/javascript" src="<%=URL%>newedition/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/aui-toast.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/aui-slide.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/aui-pull-refresh.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/aui-popup-new.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/aui-dialog.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/base.js?version=3.6"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/doRefresh.js"></script>
<script type="text/javascript" src="<%=URL%>js/cookies.js?version=1.1"></script>
<script type="text/javascript" src="<%=URL%>js/doT.min.js"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/auipopupstyle.js"></script>
<title>我的记录</title>
<style type="text/css">
.time-year>select option {
	background-color: #fff;
	color: #000
}
</style>
</head>

<body>
	<header class="aui-bar aui-bar-nav"> <!-- <a
		class="aui-pull-left aui-btn"> <span
		class="aui-iconfont aui-icon-left"></span>
	</a> -->
	<div class="aui-title">我的记录</div>
	<!--<a class="aui-pull-right aui-btn">
					<span class="aui-iconfont aui-icon-more"></span>
				</a>--> </header>
	<div class="body-box aui-refresh-content">
		<div class="time">
			<div class="time-year">
				<select id="yearall">
					<option>2017年</option>
				</select>
			</div>
			<div class="time-month">
				<i id="monthLeft" class="aui-iconfont aui-icon-left"
					tapmode="active"></i> <span id="month"></span> <span>月</span> <i
					id="monthRight" class="aui-iconfont aui-icon-right" tapmode></i>
			</div>
		</div>
		<div class="notesList-box"  id="dotmainhtml">
					<!-- <div class="notesList aui-margin-b-15">
				<div class="notesList-left">
					<span>14</span>
				</div>
				<div class="notesList-center">
					<div>收油地址：重庆市渝中区中山三路****号</div>
					<div>收油数量：10桶</div>
				</div>
				<div class="notesList-right">查看</div>
			</div> -->
		<!-- 	<div class="notesList aui-margin-b-15">
				<div class="notesList-left">
					<span>14</span>
				</div>
				<div class="notesList-center">
					<div>收油地址：重庆市渝中区中山三路****号</div>
					<div>收油数量：10桶</div>
				</div>
				<div class="notesList-right">查看</div>
			</div>
			<div class="notesList aui-margin-b-15">
				<div class="notesList-left">
					<span>14</span>
				</div>
				<div class="notesList-center">
					<div>收油地址：重庆市渝中区中山三路****号</div>
					<div>收油数量：10桶</div>
				</div>
				<div class="notesList-right">查看</div>
			</div> -->
		</div>
	</div>
</body>

<script>
$(function() {
	postMonth();
	/* alert(getLastDay(2017, 2)) */
})
		
	$('.time-year').click(function() {
		$('.time-year-ul').children('li').slideToggle(500);
	})

	function postMonth() {
		var mydate = new Date();
		var month = mydate.getMonth() + 1;
		$('#month').html(month);
		var StartDay= getStartDay(2017, month)
		var LastDay= getLastDay(2017, month);
		findlist(getCookie("salesmaniphone"), "", 9,StartDay,LastDay)
		$('#monthLeft').click(function() {
			var i = $('#month').html();
			var j = parseInt(i) - 1;
			if (i <= 1) {
				$('#month').html('12');
				var StartDay= getStartDay(2017, 12)
				var LastDay= getLastDay(2017, 12);
				findlist(getCookie("salesmaniphone"), "", 9,StartDay,LastDay)
			} else {
				$('#month').html(j);
				var StartDay= getStartDay(2017, j)
				var LastDay= getLastDay(2017, j);
				findlist(getCookie("salesmaniphone"), "", 9,StartDay,LastDay)
			}
		});
		/* $("#yearall").on("change",function(){
			var StartDay= getStartDay($("option:selected",this).val(), 12)
			var LastDay= getLastDay($("option:selected",this).val(), 12);
			findlist(getCookie("salesmaniphone"), "", 9,StartDay,LastDay)
			$("option:selected",this).val()
		}) */
		$('#monthRight').click(function() {
			var i = $('#month').html();
			var j = parseInt(i) + 1;
			if (i >= 12) {
				$('#month').html('1');
				var StartDay= getStartDay(2017, 1)
				var LastDay= getLastDay(2017, 1);
				findlist(getCookie("salesmaniphone"), "", 9,StartDay,LastDay)
			} else {
				$('#month').html(j);
				var StartDay= getStartDay(2017, j)
				var LastDay= getLastDay(2017, j);
				findlist(getCookie("salesmaniphone"), "", 9,StartDay,LastDay)
			}
		});
	}
	function getLastDay(year, month) {
		var new_year = year; //取当前的年份   
		var new_month = month++;//取下一个月的第一天，方便计算（最后一天不固定）   
		if (month > 12) //如果当前大于12月，则年份转到下一年   
		{
			new_month -= 12; //月份减   
			new_year++; //年份增   
		}
		var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天   
		return (new Date(new_date.getTime() - 1000 * 60 * 60 * 24)).Format("yyyy-MM-dd")//获取当月最后一天日期   
	}
	function getStartDay(year, month){
		var new_year = year; //取当前的年份   
		var new_month = month++;//取下一个月的第一天，方便计算（最后一天不固定）   
		if (month > 12) //如果当前大于12月，则年份转到下一年   
		{
			new_month -= 12; //月份减   
			new_year++; //年份增   
		}
		var new_date = new Date(new_year, new_month-1, 1); //取当年当月中的第一天   
		return new_date.Format("yyyy-MM-dd")//获取当月最后一天日期   
	}
	Date.prototype.Format = function(fmt) { //author: meizz
		var o = {
			"M+" : this.getMonth()+1, //月份
			"d+" : this.getDate(), //日
			"h+" : this.getHours(), //小时
			"m+" : this.getMinutes(), //分
			"s+" : this.getSeconds(), //秒
			"q+" : Math.floor((this.getMonth() + 3) / 3),
			"S" : this.getMilliseconds()
		//毫秒
		};
		if (/(y+)/.test(fmt))
			fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
					.substr(4 - RegExp.$1.length));
		for ( var k in o)
			if (new RegExp("(" + k + ")").test(fmt))
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
						: (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
	}
	function findlist(phone,orderid,roleId,start,end) {
		showDefault("loading","加载中...");
		var jsonstr = "filterscount=0&groupscount=0&pagenum=0&pagesize=1000&recordstartindex=0&recordendindex=1000&roleId="+roleId+"&phone="+phone+"&iphone="+phone+"&orderid="+orderid+"&orgstatus=4&startUpdateDt="+start+"&endUpdateDt="+end+"";
		$.ajax({
			cache: false,
			type: "post",
			datatype: 'json',
			contentType: 'application/json;charset=UTF-8',
			data: jsonstr,
			url: ''+httpipstr+'alfa-mobile-ws/rest/order/findlist?mobiletoken=' + getCookie("mobiletokensalesman") + '',
			success: function(data) {
				toast.hide();
				if(orderid==""){
					// 将数据扔进templ中。并在DIV中显示出来
					var str='';
					$.each(data.rows,function(num,value) {
						str+='<div class="notesList aui-margin-b-15">'
						+'<div class="notesList-left">'
						+'<span>'+value.realnum+'</span>'
						+'</div>'
						+'<div class="notesList-center">'
						+'<div>收油地址：'+value.address+'</div>'
						+'<div>收油数量：'+value.realnum+'桶</div>'
						+'</div>'
						+'<div class="notesList-right" onclick=a('+value.orderid+')>查看</div>'
						+'</div>'	
					})
					 $("#dotmainhtml").html(str); 
				}
			}
		});
	}
	dorefresh();
	function a(id){
		location.href="oiler_taskStatus.jsp?orderid="+id+""
	}
</script>

</html>